package com.xique.park.bean.transform.web.garageLaneDev;

import com.xique.common.core.utils.SecurityUtils;
import com.xique.park.bean.domain.ParkDeviceNew;
import com.xique.park.bean.domain.ParkLane;
import com.xique.park.bean.request.web.garageLaneDev.ipc.AddIpcRequest;
import com.xique.park.bean.request.web.garageLaneDev.ipc.EditIpcRequest;
import com.xique.park.bean.vo.web.garageLaneDeviceTree.TreeNodeIpcVo;

public class IpcTransform {

    /**
     * 主相机实体转化为Vo实体
     */
    public static TreeNodeIpcVo transformNodeIpcVo(ParkDeviceNew parkDeviceNew, ParkLane parkLane) {
        TreeNodeIpcVo treeIpcVo = new TreeNodeIpcVo();
        treeIpcVo.setLaneId(parkDeviceNew.getLaneId());
        treeIpcVo.setLaneName(parkLane.getName());
        treeIpcVo.setName(parkDeviceNew.getName());
        treeIpcVo.setDevCode(parkDeviceNew.getCode());
        treeIpcVo.setIp(parkDeviceNew.getIp());
        treeIpcVo.setBoardType(parkDeviceNew.getControlType());
        //余位屏控制板？
        treeIpcVo.setStatus(parkDeviceNew.getStatus());
        treeIpcVo.setSort(null != parkDeviceNew.getSort() ? parkDeviceNew.getSort() : 1L);
        treeIpcVo.setType("ipc");
        treeIpcVo.setCreateTime(parkDeviceNew.getCreateTime());
        treeIpcVo.setUpdateTime(parkDeviceNew.getUpdateTime());
        return treeIpcVo;
    }

    /**
     * 添加主相机request转化为parkDeviceNew实体
     */
    public static ParkDeviceNew transformAddIpcRequest(AddIpcRequest request) {
        ParkDeviceNew parkDeviceNew = new ParkDeviceNew();
        parkDeviceNew.setParkId(SecurityUtils.getParkId());
        parkDeviceNew.setStatus(request.getStatus());
        parkDeviceNew.setName(request.getName());
        parkDeviceNew.setLaneId(request.getLaneId());
        parkDeviceNew.setCode(request.getDevCode());
        parkDeviceNew.setIp(request.getIp());
        parkDeviceNew.setControlType(request.getBoardType());
        parkDeviceNew.setSort(request.getSort());
        parkDeviceNew.setIsMain("Y");
        return parkDeviceNew;
    }

    /**
     * 编辑主相机request转化为parkDeviceNew实体
     */
    public static ParkDeviceNew transformEditIpcRequest(EditIpcRequest request) {
        ParkDeviceNew parkDeviceNew = new ParkDeviceNew();
        parkDeviceNew.setParkId(SecurityUtils.getParkId());
        parkDeviceNew.setStatus(request.getStatus());
        parkDeviceNew.setName(request.getName());
        parkDeviceNew.setLaneId(request.getLaneId());
        parkDeviceNew.setCode(request.getDevCode());
        parkDeviceNew.setIp(request.getIp());
        parkDeviceNew.setControlType(request.getBoardType());
        parkDeviceNew.setSort(request.getSort());
        parkDeviceNew.setId(request.getId());
        parkDeviceNew.setIsMain("Y");
        return parkDeviceNew;
    }

}
